﻿@model List<MVCApp.Models.Person>

@{
    Layout = null;
    int counter = 1;
    
    string columnsWidth = "";
    
    if(ViewBag.IsMultiPostCode)
    {
        columnsWidth = "1;6;6;2;4";
    }
    else
    {
        columnsWidth = "1;7;7;4";
    }

    string lastStreetAddress = ""; 
}

<itext creationdate="@DateTime.Now.ToString()">

    <paragraph style="font-size:14;font-family:Calibri;font-weight:bold;color:darkgray;text-decoration:underline">
        <chunk>@ViewBag.DistrictName, </chunk>
        <chunk>@ViewBag.DistrictPostCode</chunk>
    </paragraph>

    <table width="100%" cellpadding="1.0" cellspacing="1.0"  widths="@columnsWidth">
        <row>
            <cell borderwidth="0.5" left="false" right="false" top="false" bottom="true">
                <chunk style="font-weight:bold">#</chunk>
            </cell>

	        <cell borderwidth="0.5" left="false" right="false" top="false" bottom="true">
                <chunk style="font-weight:bold">@Html.DisplayNameFor(model => model.First().Name)</chunk>
	        </cell>
	        <cell borderwidth="0.5" left="false" right="false" top="false" bottom="true">
                <chunk style="font-weight:bold">@Html.DisplayNameFor(model => model.First().StreetAddress)</chunk>
	        </cell>
            @if(ViewBag.IsMultiPostCode)
            {
            <cell borderwidth="0.5" left="false" right="false" top="false" bottom="true">
                <chunk style="font-weight:bold">@Html.DisplayNameFor(model => model.First().PostCode)</chunk>
	        </cell>
            }
	        <cell borderwidth="0.5" left="false" right="false" top="false" bottom="true">
                <chunk style="font-weight:bold">@Html.DisplayNameFor(model => model.First().TelephoneNumber)</chunk>
	        </cell>            
        </row>

    @foreach (var item in Model)
    {
        <row>

            <cell>
                <chunk style="font-size:11;">
                @if(lastStreetAddress != item.StreetAddress)
                {
                    @counter@:.
                    counter = counter + 1;
                }
                @{ lastStreetAddress = item.StreetAddress; }
                </chunk>
            </cell>

            <cell>
                <chunk style="font-size:11;">@item.Name @item.Lastname</chunk>
            </cell>

	        <cell>
                <chunk style="font-size:11;">@item.StreetAddress</chunk>
            </cell>
           
            @if(ViewBag.IsMultiPostCode)
            {
            <cell>
                <chunk style="font-size:11;">@item.PostCode</chunk>
            </cell>
            }
            <cell>
                <chunk style="font-size:11;">@item.TelephoneNumber</chunk>
            </cell>
            
        </row>
    }
    </table>
</itext>
